/*
 * Arrow.fx
 *
 * Created on Jun 27, 2009, 3:12:27 PM
 */

package fxbattle.fxgui;

import javafx.scene.CustomNode;
import javafx.scene.paint.Color;
import javafx.scene.Node;
import javafx.scene.Group;
import javafx.scene.shape.Line;
import javafx.scene.transform.Transform;

/**
 * @author spina
 */
// TODO This wouldn't compile when it was named "Arrow" is that a reserved word? Seems like a bug in the compilier..
public class FlowArrow extends CustomNode {

    public var strokeWidth = 4.0;
    public var stroke = Color.BLACK;
    public var length = 0.0;

    public override function create(): Node {
        def lines = Group{};
        insert Line {
            startX: 0
            startY: 0
            endX: length
            endY: 0
            strokeWidth: bind strokeWidth
            stroke: bind stroke
            effect: bind effect
        } into lines.content;

//        insert Polygon {
//			points: [0, 0, -1 * strokeWidth * 2, 10, strokeWidth * 2, 10]
//   		    fill: bind stroke
//            effect: bind effect
//            transforms: [Transform.translate(endx, endy), Transform.rotate(90, 0, 0)]
//        } into lines.content;

        insert Line {
            startX: 0
            startY: 0
            endX: length
            endY: 0
            strokeWidth: bind strokeWidth
            stroke: bind stroke
            effect: bind effect
            transforms: [Transform.scale(.3, 1, length, 0), Transform.rotate(10, length, 0)]
        } into lines.content;

        insert Line {
            startX: 0
            startY: 0
            endX: length
            endY: 0
            strokeWidth: bind strokeWidth
            stroke: bind stroke
            effect: bind effect
            transforms: [Transform.scale(.3, 1, length, 0), Transform.rotate(-10, length, 0)]
        } into lines.content;

        lines;
    }

}
